Helpful Information
 
 
Category: File Size Uploads
File Size Uploads > 2MB

If someone wants to allow users to upload files larger than 2MB on a shared server, how could this be done? Would the script need to be written in another language such as Java or Perl?

upload_max_filesize can be set in a .htaccess file in PHP versions greater than 4.2.3 and it was also settable in your script prior to this.

post_max_size is also settable in the same situations as upload_max_filesize.

If a file is bigger than 2Mb then it is far more efficient to upload it with FTP. If your PHP setup has the FTP extensions enabled then you could use that, alternatively you could set up an anonymous FTP server for people to upload those files. The reason for the 2Mb limit is that the normal method that PHP uses for uploading files becomes extremely inefficient once the files are that big.

Question on the FTP extensions on PHP:

Wouldn't that still be subject to the max_file_upload and max_post_size directives?

The way I understand the PHP FTP functions is it will login to an FTP server and transfer a file using FTP from the server on which php is running to the FTP server. If you have a client computer, that needs to upload to the sever where the PHP script is, that's still subject to the same limitations, right?

For example:

User A has a computer and connects to www.example.com/upload.php
He want's to upload a 5MB file to that server.

Regardless of the FTP functions being enabled, PHP still uses HTTP to upload from User A's computer to the www.example.com site and would therefore be subject to the php.ini directives, right?

Yes , unless the user is using an FTP client FTP functions do not help since you are still tied to HTTP.

You could also use an iframe with an ftp://[email protected] as the source that will allow your users to drag'n'drop large files to an anonymous FTP account... or you could just alter the upload size in the php.ini










privacy (GDPR)